home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / nullmodem / src / init.c < prev    next >
C/C++ Source or Header  |  1995-12-18  |  2KB  |  88 lines

  1. #include "defs.h"
  2. #include "protos.h"
  3. #include "nullrev.h"
  4.  
  5. long start(void) { return(-1); } /* in case somebody tries to run us */
  6.  
  7. struct NullBase *DevBase = NULL;
  8. struct ExecBase *SysBase = NULL;
  9.  
  10. char ID[] = "$VER: nullmodem "__VERSION__" ("__COMMODORE_DATE__") © 1993, 1994 Iain Hibbert\r\n";
  11. char DeviceName[] = "nullmodem.device";
  12.  
  13. /*
  14.  *  the RomTag structure (const puts it in the code segment)
  15.  */
  16. const struct Resident RomTag = {
  17.     RTC_MATCHWORD,
  18.     &RomTag,
  19.     &RomTag+1,              /* EndCode */
  20.     0,                      /* no flags */
  21.     VERSION,
  22.     NT_DEVICE,
  23.     0,                      /* zero priority */
  24.     DeviceName,
  25.     ID,
  26.     DevInit
  27. };
  28.  
  29. /*
  30.  *  initialise device (in a Forbid)
  31.  *
  32.  *  NOTE! this is the first piece of code called, and as we have NO startup
  33.  *        code anywhere, we have to set up SysBase etc ourselves.. there is
  34.  *        NO auto-initialisation code anywhere, NO memory allocation, NO
  35.  *        clearing of BSS space.. we are totally on our own..
  36.  *
  37.  *  segment pointer in A0
  38.  */
  39. struct NullBase *
  40. DevInit(__A0 APTR seg)
  41. {
  42. struct NullBase *db;
  43. static APTR func_table[] = {
  44.     DevOpen,
  45.     DevClose,
  46.     DevExpunge,
  47.     DevReserved,
  48.     DevBeginIO,
  49.     DevAbortIO,
  50.     -1
  51. };
  52.  
  53.     SysBase = *(struct ExecBase **)4;
  54.  
  55.     db = (struct NullBase *)MakeLibrary(func_table, NULL, NULL, sizeof(struct NullBase), NULL);
  56.  
  57.     if( db ) {
  58.  
  59.         /*
  60.          *  set up the device structure
  61.          */
  62.         DevBase = db;
  63.  
  64.         db->b_Lib.lib_Node.ln_Type = NT_DEVICE;
  65.         db->b_Lib.lib_Node.ln_Name = DeviceName;
  66.         db->b_Lib.lib_Flags = LIBF_CHANGED | LIBF_SUMUSED;
  67.         db->b_Lib.lib_Version = VERSION;
  68.         db->b_Lib.lib_Revision = REVISION;
  69.         db->b_Lib.lib_IdString = ID;
  70.         db->b_Segment = seg;
  71.  
  72.         /*
  73.          *  online at last!
  74.          */
  75.         AddDevice((struct Device *)db);
  76.  
  77.     }
  78.  
  79.     return(db);
  80. }
  81.  
  82. void NewList(struct List *list)
  83. {
  84.     list->lh_Head     = (struct Node *)&list->lh_Tail;
  85.     list->lh_Tail     = NULL;
  86.     list->lh_TailPred = (struct Node *)&list->lh_Head;
  87. }
  88.